package com.servlet;

import com.entity.User;
import com.service.RegisterService;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class RegisterController extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        // 处理注册逻辑
        RegisterService registerService = new RegisterService();
        //获取所有注册数据
        String username=(String)request.getParameter("username");
        String password=(String)request.getParameter("password");
        String identity=(String)request.getParameter("identity");
        String phone=(String)request.getParameter("phone");

        User user = new User(username,password,identity,phone);
        registerService.register(user);
        response.sendRedirect("login.jsp"); //返回登录页面
    }
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
    }
}

